// components/playList/playlist.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    playlist: Object
  },

  /**
   * 数据监听器
   */
  observers: {
    ["playlist.playCount"](count) { 
      this.setData({
        _count: this._tranNumber(count, 2)
      });
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    _count: 0
  },

  /**
   * 组件的方法列表
   */
  methods: {

    goToMusiclist() {
      wx.navigateTo({
        url: `../../pages/musiclist/musiclist?playlistId=${this.properties.playlist.id}`,
      })
    },
    /**
     * 数量格式化
     */
     _tranNumber(num, point) {
       let numStr = num.toString().split(".")[0];
       let len = numStr.length;
       if (len < 6) {
         return numStr;
       } else if (len >= 6 & len <= 8) {
         let decimal = numStr.substring(len - 4, len - 4 + point);
         return parseFloat(parseInt(num / 10000) + "." + decimal) + "万";
       } else if (len > 8) {
         let decimal = numStr.substring(len - 8, len - 8 + point);
         return parseFloat(parseInt(num / 100000000) + "." + decimal) + "亿";
       }
     }
  }
})
